<template>
    <div class="projectmenu_wrap">
        <el-row class="project_name" type="flex" justify="space-between">
        <font :class="{editcolor_false: detail.status != 1}">{{detail.name ? detail.name : '项目ID:' + pid}}</font>
        <div v-if="isAdmin">
            <router-link :to="{path:'/projectperson/' + pid}">
            <el-button type="primary" size="mini">项目人员管理</el-button>
            </router-link>
        </div>
        </el-row>
        <div class="project_menu">
        <el-menu
            :default-active="navselected"
            class="el-menu-demo"
            mode="horizontal"
            router
            unique-opened
        >
            <el-menu-item :index="'/details/' + pid">看板</el-menu-item>
            <!-- <el-menu-item :index="'/audience/' + pid">定向</el-menu-item>
            <el-menu-item :index="'/material/' + pid">素材</el-menu-item>
            <el-menu-item :index="'/implement/' + pid">实施</el-menu-item>
            <el-menu-item :index="'/tasks/' + pid">任务</el-menu-item> -->
        </el-menu>
        </div>
    </div>
</template>
<style scoped>
.projectmenu_wrap {
    background-color: #fff;
    padding: 15px 0;
    border-radius: 6px;
    margin-top: 15px;
  /* box-shadow: 1px 2px 4px rgb(0, 0, 0, 0.1); */
}

.projectmenu_wrap .project_name {
    font-size: 14px;
    color: #333;
    padding: 0 20px;
}
.projectmenu_wrap .project_name font {
    font-size: 16px;
}

.projectmenu_wrap .project_name button {
    margin-left: 10px;
}
.project_menu {
    margin-top: 10px;
}
.project_menu .el-menu-item {
    height: auto;
    line-height: normal;
}

.project_menu .el-menu.el-menu--horizontal {
    border-bottom: none;
}
.project_menu .el-menu--horizontal > .el-menu-item {
    height: auto;
    line-height: normal;
}

.project_menu .el-menu--horizontal > .el-menu-item.is-active {
    border-bottom: none;
    color: #409eff;
}
</style>
<script>
import { isMember } from '@/settings'
export default {
    props: {
        detail: {
            type: Object,
            default: function () {
                return { name: "未知项目" };
            },
        },
        pid: {
        // type: String,
        // default: ''
        // require: true // 必填
        },
    },
    data() {
        return {
            navselected: '',
            isAdmin: false,
        };
    },
    mounted() {
        if (!this.pid) {
            console.error('参数错误,projectmenu.vue无法取得pid')
        }
        // console.log('menu mouted', this.$route.meta.projectMenu + '/' + this.pid)
        this.navselected = this.$route.meta.projectMenu + '/' + this.pid
        this.isAdmin = !isMember(this.$store.state.user.id_role)
    },
    watch: {
        detail: function() {
            // console.log('detail', this.detail)
            if (!this.isAdmin) {
                this.isAdmin = this.detail.id_manager == this.$store.state.user.uid
            }
        }
    }
    // computed: {
        // details () {
        //     return '/details/' + this.pid
        // },
        // audience() {
        //     return '/audience/' + this.pid
        // }
    //     projectMenu() {
    //         const route = this.$route
    //         const {
    //             meta,
    //             path
    //         } = route
    //         if (meta.projectMenu) {
    //         console.log(meta.projectMenu + '/' + this.pid)
    //             return meta.projectMenu + '/' + this.pid
    //         }
    //         return path
    //     }
    // },
};
</script>